package com.kun.service.role;

import com.kun.dao.BaseDao;
import com.kun.dao.role.RoleDao;
import com.kun.dao.role.RoleDaoImpl;
import com.kun.entity.Role;
import org.junit.Test;

import java.sql.Connection;
import java.sql.SQLException;
import java.util.ArrayList;

public class RoleServiceImpl implements RoleService{
    private RoleDao roleDao;

    public RoleServiceImpl() {
        this.roleDao = new RoleDaoImpl();
    }

    //获取角色信息列表
    public ArrayList<Role> getRoleList() {
        Connection connection = null;
        ArrayList<Role>list = null;

        try {
            connection = BaseDao.getConnection();
            list = roleDao.getRoleList(connection);
        } catch (SQLException e) {
            e.printStackTrace();
        }finally {
            BaseDao.closeResource(connection);
        }

        return list;
    }

    @Test
    public void test(){
        RoleService roleService = new RoleServiceImpl();

//        //getRoleList()
//        ArrayList<Role> roleList = roleService.getRoleList();
//        for (Role role : roleList) {
//            System.out.println(role.getRoleName());
//        }


    }
}
